import axios from "axios";
import store  from '@/store'

const service = axios.create({
  baseURL: '/api',
  timeout: 10000
})

service.interceptors.request.use((config) =>{
  // 查看store下有没有存储token
  if(store.getters.token){
    config.headers.Authorization = `Bearer ${store.getters.token}`
  }
  return config
}, (error) =>{
  // 错误执行promise
  return Promise.reject(error)
})
export default service